<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改商机跟踪')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-chance-edit" th:object="${sjChance}">
            <input name="id" th:field="*{id}" type="hidden" />
            <input name="deptId" th:field="*{deptId}" type="hidden" />
            <input name="ownerId" th:field="*{ownerId}" type="hidden" />
            <input type="hidden" id="approvename" name="approvename" th:value="${approvename}" />
            <div class="form-group">
            	<label class="col-sm-2 control-label is-required">申报部门：</label>
                <div class="col-sm-4">
                    <input name="dept" th:field="*{dept}" class="form-control" type="text" readonly="readonly" autoComplete="off" required>
                </div>
            	<label class="col-sm-2 control-label is-required">申报人：</label>
                <div class="col-sm-4">
                    <input name="owner" th:field="*{owner}" class="form-control" type="text" readonly="readonly" autoComplete="off" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label is-required">项目描述：</label>
                <div class="col-sm-10">
                    <textarea name="descs" class="form-control" required autoComplete="off">[[*{descs}]]</textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label is-required">客户单位：</label>
                <div class="col-sm-4">
                    <div class="input-group">
                    	<input id="customerName" th:field="*{customerName}" class="form-control" type="hidden">
                    	<input id="customerId" th:field="*{customerId}" class="form-control" type="hidden">
                    	<input class="form-control" type="text" onclick="selectCustomer()" id="customerStr" th:value="*{customerName}" readonly="true" required>
						<span class="input-group-addon"><i class="fa fa-search"></i></span>
					</div>
                </div>
                <label class="col-sm-2 control-label is-required">项目董事：</label>
                <div class="col-sm-4">
                	<div class="input-group">
                    	<input id="xmds" th:field="*{xmds}" class="form-control" type="hidden">
                    	<input id="xmdsId" th:field="*{xmdsId}" class="form-control" type="hidden">
                    	<input class="form-control" type="text" onclick="selectlevel1()" id="xmdsStr" th:value="*{xmds}" readonly="true" required>
						<span class="input-group-addon"><i class="fa fa-search"></i></span>
					</div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label is-required">开始日期：</label>
                <div class="col-sm-4">
                    <div class="input-group date">
                        <input name="startAt" th:value="${#dates.format(sjChance.startAt, 'yyyy-MM-dd')}" autoComplete="off" required class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
                <label class="col-sm-2 control-label is-required">结束日期：</label>
                <div class="col-sm-4">
                	<div class="input-group date">
                        <input name="endAt" th:value="${#dates.format(sjChance.endAt, 'yyyy-MM-dd')}" autoComplete="off" required class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group"> 
                <label class="col-sm-2 control-label is-required">业务分类：</label>
                <div class="col-sm-4">
                    <select name="ywx" th:field="*{ywx}" class="form-control" th:with="type=${@dict.getType('sj_nsct_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
                <label class="col-sm-2 control-label is-required">优先级：</label>
                <div class="col-sm-4">
                    <select id="yxj" name="yxj" th:field="*{yxj}" class="form-control" required>
						<option value="低">低</option>
						<option value="中">中</option>
						<option value="高">高</option>
					</select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label is-required">战略机会：</label>
                <div class="col-sm-4">
                    <select id="zljh" name="zljh" th:field="*{zljh}" class="form-control" required>
						<option value="是">是</option>
						<option value="否">否</option>
					</select>
                </div>
                <label class="col-sm-2 control-label is-required">风险等级：</label>
                <div class="col-sm-4">
                    <select id="fxdj" name="fxdj" th:field="*{fxdj}" class="form-control" required>
						<option value="无">无</option>
						<option value="低">低</option>
						<option value="中">中</option>
						<option value="高">高</option>
					</select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label ">报价合计：</label>
                <div class="col-sm-4">
                    <input name="bjhj" class="form-control" th:field="*{bjhj}" type="number" autoComplete="off" >
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">备注：</label>
                <div class="col-sm-10">
                    <textarea name="memo" class="form-control" autoComplete="off">[[*{memo}]]</textarea>
                </div>
            </div>
        </form>
    </div>
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "sj/chance";
        $("#form-chance-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.saveTab(prefix + "/edit", $('#form-chance-edit').serialize());
            }
        }

        $("input[name='startAt']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='endAt']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        
      //选择用户level1
		function selectlevel1() {
			var options = {
		       title: '选择用户',
		       url: "/sj/config/invokeUser",
		       width: '1000',
		       height: '670',
		       callBack: doSubmitlevel1User
		    };
		    $.modal.openOptions(options);
		}
	 	
		function doSubmitlevel1User(index, layero){
            var rows = layero.find("iframe")[0].contentWindow.getSelections();
            if (rows.length == 0) {
                $.modal.alertWarning("请选择一条记录！");
                return;
            }
            
            if (rows.length > 1) {
                $.modal.alertWarning("请勿选择多条记录！");
                return;
            }
            
            $("#xmdsId").val(rows[0].userId);
            $("#xmds").val(rows[0].userName);
            $("#xmdsStr").val(rows[0].userName);
            $.modal.closeAll();
        }
		
		
		//选择用户Customer
		function selectCustomer() {
			var options = {
		       title: '选择用户',
		       url: "/gcgl/customer/invokeCustomer",
		       width: '1000',
		       height: '670',
		       callBack: doSubmitCustomer
		    };
		    $.modal.openOptions(options);
		}
	 	
		function doSubmitCustomer(index, layero){
            var rows = layero.find("iframe")[0].contentWindow.getSelections();
            if (rows.length == 0) {
                $.modal.alertWarning("请选择一条记录！");
                return;
            }
            
            if (rows.length > 1) {
                $.modal.alertWarning("请勿选择多条记录！");
                return;
            }
            
            $("#customerId").val(rows[0].id);
            $("#customerName").val(rows[0].name);
            $("#customerStr").val(rows[0].name);
            $.modal.closeAll();
        }

    </script>
</body>
</html>